package com.rec.controller;

import com.common.domain.dto.RecAddDTO;
import com.common.domain.dto.RecUpdateSortNumDTO;
import com.common.result.Result;
import com.rec.service.RecService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 路亚
 * @version 0.1
 * @className RecController
 * @description
 * @date 2024/12/13 20:34
 * @since jdk11
 */
@RestController
@RequestMapping("/rec")
@Slf4j
@RequiredArgsConstructor
@Api(tags = "推荐管理")
public class RecController {

    private final RecService recService;

    @PostMapping("/add")
    @ApiOperation("新增推荐")
    public Result addRec(@RequestBody List<RecAddDTO> recAddDTOList) {
        log.info("新增推荐,参数为:{}", recAddDTOList);
        recService.addRec(recAddDTOList);
        return Result.success();
    }

    @PostMapping("/update/sortNum")
    @ApiOperation("修改推荐顺序")
    public Result updateSortNum(@RequestBody List<RecUpdateSortNumDTO> dtoList) {
        log.info("修改推荐顺序,参数为:{}", dtoList);
        recService.updateSortNum(dtoList);
        return Result.success();
    }

    @DeleteMapping("/deleteByIds")
    @ApiOperation("删除推荐的短剧")
    public Result deleteByIds(@RequestBody List<Long> ids) {
        log.info("删除推荐的短剧,参数为:{}", ids);
        recService.removeByIds(ids);
        return Result.success();
    }

    @GetMapping("/queryAll")
    @ApiOperation("查询所有推荐的短剧")
    public Result queryAll() {
        log.info("查询所有推荐的短剧");
        Result result = recService.queryAll();
        return result;
    }

    @GetMapping("/queryByCarousel")
    @ApiOperation("查询轮播图推荐")
    public Result queryByCarousel() {
        log.info("查询轮播图推荐");
        return recService.queryAllByCarousel();
    }
}
